from functools import reduce
class Solution(object):
    def addDigits(self, num):
        """
        :type num: int
        :rtype: int
        """
        while num >= 10:
            num = reduce(lambda x, y: int(x) + int(y), str(num))
        
        return num
        
s = Solution()
print(s.addDigits(38)) # t